<?php
include("connect.php");
$con = conecta();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Portal multim&iacute;dia</title>
    <link href="css/style.css" rel="stylesheet" type="text/css" media="screen"/>
	<script src="js/jquery.min.js"></script>
	<script src="js/jquery.corner.js"></script>
    <script src="js/flowplayer-3.2.6.min.js"></script>
	<script>
		$(document).ready(function(){
			$("#uploadbar").corner();
			$("#header").corner();
			$(".thumbnail").corner();
			$("#list").corner();
			$("#footer").corner();
			$("#flowplayer").corner();
                        $("#video_info").corner();
		})
		
	</script>
</head>

<body>
<div id="wrapper">
    <div id="header">Portal multim&iacute;dia</div>
    <div id="uploadbar">
        <form action="upload.php" method="post" enctype="multipart/form-data">
            T&iacute;tulo&nbsp;<input id="inputtitulo" type="text" name="titulo" />
            &nbsp;&nbsp;Arquivo&nbsp;<input type="file" name="arquivo" >
            &nbsp;&nbsp;<input type="submit" value="Enviar" />
        </form>
    </div>
    <div id="main">
        <div id="list">
            <div id="videos">Videos</div>
            <?php
				$sql = mysql_query("SELECT titulo,id,frame_name FROM videos");
				while($ar = mysql_fetch_array($sql))
					echo '<div class="thumbnail left">
                                                <a href="?video='.$ar['id'].'">
                                                   <img src="frames/'.$ar['frame_name'].'" width="150px" height="120px" />
                                                </a>
                                                <a class="titico" href="?video='.$ar['id'].'">'.$ar['titulo'].'</a>
                                              </div>';    
                                        
            ?>
        </div>
        <div id="flowplayer">
            <?php
				if(isset($_GET['video'])){
					$sql2 = mysql_query("SELECT * FROM videos WHERE id='$_GET[video]'");
					$ar2 = mysql_fetch_array($sql2);
					$video = "videos/".$ar2['file_name'];
					$titulo = $ar2['titulo'];
					$resolucao = $ar2['resolucao'];
					$duracao = $ar2['duracao'];
					$framerate = $ar2['framerate'];
					$bitrate = $ar2['bitrate'];
				}else{
					//$video e $titulo vem do banco de dados pela consulta do id que estiver na url
					$video = "http://pseudo01.hddn.com/vod/demo.flowplayervod/flowplayer-700.flv";
					$titulo = "Titulo do video";
				}
            ?>
            <div id="titulo"><?php echo $titulo ?></div>
            <a href="<?php echo $video ?>" style="display:block;width:425px;height:320px;margin:auto;" id="player"></a>
            <script language="JavaScript">flowplayer("player", "flowplayer/flowplayer-3.2.7.swf");</script>
			
			<?php
                                $hora = (int) ($duracao / 3600);
                                $minuto = (int) (($duracao % 3600) /60);
                                $segundo = ($duracao % 3600) % 60;
                                if(isset($_GET['video']))
				echo "
                                <div id='video_info'>
				<table cellspacing=6>
					<tr>
						<td>&nbsp;<b>Resolu&ccedil;&atilde;o</b>&nbsp;</td>
						<td>&nbsp;$resolucao&nbsp;</td>
						<td>&nbsp;<b>Dura&ccedil;&atilde;o</b>&nbsp;</td>
						<td>&nbsp;$hora h $minuto m $segundo s&nbsp;</td>
					<tr>
					<tr>
						<td>&nbsp;<b>Framerate</b>&nbsp;</td>
						<td>&nbsp;$framerate fps&nbsp;</td>
						<td>&nbsp;<b>Bitrate</b>&nbsp;</td>
						<td>&nbsp;$bitrate kbps&nbsp;</td>
					<tr>
				</table>
                                </div>";
				?>
			
        </div>
    </div>
    <div id="footer">Grupo: Davi Bandeira, &Eacute;rico Ramos e Walter Travassos</div>
</div>
</body>
</html>
<?php
mysql_close($con);
?>
